
#include<iostream>
#include<sys/types.h>
#include<sys/shm.h>
#include<unistd.h>
#include<sys/ipc.h>
#include<string>

using std::cout;
using std::endl;

const std::string Pathname = "/home/ddsm/_11_26_work";
const int proj_id = 0x55;

enum NUM
{
	SIZE = 4096,
};

int main()
{
	key_t key = ftok(Pathname.c_str(),proj_id);
	if(key < 0)
	{
		perror("ftok fail!");
		exit(1);
	}

	int shmid = shmget(key,SIZE,IPC_CREAT | 0666);
	if(shmid < 0)
	{
		perror("shmget fail!");
		exit(1);
	}
	//get shm done

	char* pshm = (char*)shmat(shmid,nullptr,0);
	
	cout<<pshm<<endl;	

	shmdt(pshm);
	cout<<"Process B use shm done!"<<endl;	
	return 0;
}
